package nachos.vm;

import java.util.LinkedList;

import nachos.machine.*;
import nachos.threads.*;
import nachos.userprog.*;
import nachos.vm.*;

/**
 * A kernel that can support multiple demand-paging user processes.
 */
public class VMKernel extends UserKernel {
	
	public VMSwap swap;
	public InvertPageTable pageTable = null;
	protected static Processor processor = Machine.processor();
	public int faultcounter = 0;

	/**
	 * Allocate a new VM kernel.
	 */
	public VMKernel() {
		super();
	}

	/**
	 * Initialize this kernel.
	 */
	public void initialize(String[] args) {
		super.initialize(args);
		pageTable = new InvertPageTable();
		swap = new VMSwap();
	}

	/**
	 * Test this kernel.
	 */
	public void selfTest() {
		super.selfTest();
	}

	/**
	 * Start running user programs.
	 */
	public void run() {
		super.run();
	}

	/**
	 * Terminate this kernel. Never returns.
	 */
	public void terminate() {
		// delete temp swap file
		swap.getSwapfile().close();
//		Lib.debug('x', "Num page faults = " + faultcounter);
		super.terminate();
	}

	// dummy variables to make javac smarter
	private static VMProcess dummy1 = null;
	private static final char dbgVM = 'v';
	
	
	//protected static LinkedList<Integer> globalPageTable = null;
	protected static boolean globalPageTableInitialized = false;
}
